<?php
/* @var $this EventController */
/* @var $model Event */

$this->breadcrumbs=array(
	Yii::t('Event','Events')=>array('admin'),
	Yii::t('base','Manage'),
);
Yii::app()->clientScript->registerScript('search', "
$('#search-form form').submit(function(){
	$('#event-grid').yiiGridView('update', {
		data: $(this).serialize()
	});
	return false;
});
");
?>
<div class="row-fluid">
	<div class="span12">
    	<div class="box gradient">
        	<div class="title">
           	<?php echo CHtml::link(Yii::t('common','Advanced Search'),'#collapseOne',array('class'=>'search-button accordion-toggle collapsed btn btn-mini zyBtn03','data-toggle'=>'collapse','data-parent'=>'#accordion2')); ?>
             <?php if(Yii::app()->user->level() == 1){?>
             <?php echo CHtml::link(Yii::t('common','Create'), array('create'),array('class'=>'btn btn-small create',));?>             
            <?php }?>
             <h3> <i class="icon-sitemap"></i> <span><?php echo Yii::t('Event','Manage Events') ?></span> </h3>
            </div>
            
			<div class="content"> 
			
 			<!--search start-->
 			
              <?php $this->renderPartial('_search',array(
					'model'=>$model,
				)); ?>
              
            <!--search over-->
            
            <!-- table start -->
            
<?php $this->widget('application.extensions.zgrid.ZGridView', array(
	'id'=>'event-grid',
	'dataProvider'=>$model->search(),
	'itemsCssClass'=>'responsive table table-striped table-bordered',
	'pager'=>array('class'=>'CLinkPager','hiddenPageCssClass'=>'','firstPageCssClass'=>'first paginate_button','htmlOptions'=>array('class'=>'dataTables_paginate paging_full_numbers"'),'header'=>""),
	'pagerCssClass'=>'pagination',
	'cssFile'=>false,
	'template'=>'{items}{summary}{pager}',
	'columns'=>array(
		array('name'=>'user_id','headerHtmlOptions'=>array('style'=>'width:10%'),'value'=>'Event::model()->getPartnersName($data->user_id)'),
		//array('name'=>'event_id','headerHtmlOptions'=>array('style'=>'width:10%')),
		array('name'=>'event_title','headerHtmlOptions'=>array('style'=>'width:10%')),
		//array('name'=>'event_content','headerHtmlOptions'=>array('style'=>'width:10%')),
		array('name'=>'event_code','headerHtmlOptions'=>array('style'=>'width:10%')),
		array('name'=>'start_time','headerHtmlOptions'=>array('style'=>'width:10%')),
		array('name'=>'end_time','headerHtmlOptions'=>array('style'=>'width:10%')),
		array('name'=>'award_expiry_date','headerHtmlOptions'=>array('style'=>'width:10%')),
		array('name'=>'prize_qty','headerHtmlOptions'=>array('style'=>'width:10%')),
		array('name'=>'url','headerHtmlOptions'=>array('style'=>'width:10%')),
		array(
			'class'=>'CButtonColumn',
			'header' => Yii::t ( 'common', 'Operater' ),
			'template'=>'{view} {update} {delete} {setup} {Auto Draw}{Manually Draw} {Export}',
			'headerHtmlOptions'=>array('style'=>'width:10%'),
	    	'buttons'=>array (
		        'update'=> array(
		            'label'=>'<i class="gicon-edit"></i>',
		            'imageUrl'=>0,
		            'options'=>array( 'class'=>'btn btn-small','rel'=>'tooltip','data-placement'=>'left','title'=>Yii::t('common','Update')),
		        ),
		        'view'=>array(
		            'label'=>'<i class="gicon-eye-open"></i>',
		            'imageUrl'=>0,
		            'options'=>array('class'=>'btn btn-small','rel'=>'tooltip','data-placement'=>'left','title'=>Yii::t('common','View')),
		        ),
		        'delete'=>array(
		            'label'=>'<i class="gicon-remove icon-white"></i>',
		            'imageUrl'=>0,
		             'options'=>array( 'class'=>'btn btn-inverse btn-small','rel'=>'tooltip','data-placement'=>'left','title'=>Yii::t('common','Delete')),
		        ),
		           'setup'=>array(
		            'label'=>Yii::t('Event','Setup'),
		            'url'=>'Yii::app()->createUrl("eventAwardSms/create",array("event_id"=>$data->event_id))',
		            'imageUrl'=>0,
		            'options'=>array('class'=>'btn btn-small','rel'=>'tooltip','data-placement'=>'left','title'=>Yii::t('Event','Setup')),
		       		'visible'=>'Yii::app()->user->level() == 1',
		        ),
		        	'Auto Draw'=>array(
				'label'=>Yii::t('base','Auto Draw'),
				'url'=>'Yii::app()->createUrl("eventCustomer/create",array("event_code"=>$data->event_code,"event_id"=>$data->event_id))',
				'options'=>array('class'=>'btn btn-small'),
				'visible'=>'($data->award_expiry_date > date("Y-m-d"))&&Yii::app()->user->level() == 9',//活动未过期才显示此按钮
				),
				'Manually Draw'=>array(
				'label'=>Yii::t('base','Manually Draw'),
				'url'=>'Yii::app()->createUrl("eventCustomer/lottery",array("user_id"=>$data->user_id,"event_code"=>$data->event_code,"event_id"=>$data->event_id))',
				'options'=>array('class'=>'btn btn-small'),
				'visible'=>'(($data->award_expiry_date > date("Y-m-d"))||Event::model()->getCount($data->event_id)<$data->prize_qty)&&Yii::app()->user->level() == 9',//活动未过期才显示此按钮
				),
					'Export'=>array(
						'label'=>Yii::t('base','Export'),
						'url'=>'Yii::app()->createUrl("eventCustomer/export",array("event_code"=>$data->event_code))',
						'options'=>array('class'=>'btn btn-small'),
						'visible'=>'Yii::app()->user->level() == 9',
				),
		     ),
	    ),
	),
)); ?>
					<!--table over -->
			</div><!--//content-->
		</div><!--//box-->
	</div><!--//span12-->
</div><!--//row-fluid-->
